<!DOCTYPE html>

<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width">
	<title>Documentation Source: i18n/index.js</title>

	<!--[if lt IE 9]>
	<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->
	<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">

	<link type="text/css" rel="stylesheet" href="styles/site.simplex.css">

</head>

<body>

<div class="navbar navbar-default navbar-fixed-top ">
<div class="container">
	<div class="navbar-header">
		<a class="navbar-brand" href="index.html">Documentation</a>
		<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
			<span class="icon-bar"></span>
        </button>
	</div>
	<div class="navbar-collapse collapse" id="topNavigation">
		<ul class="nav navbar-nav">
			
			<li class="dropdown">
				<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="module-app.html">app</a></li><li><a href="module-article-card.html">article-card</a></li><li><a href="module-article-detail.html">article-detail</a></li><li><a href="module-article-item.html">article-item</a></li><li><a href="module-article-module.html">article-module</a></li><li><a href="module-back.html">back</a></li><li><a href="module-banner-module.html">banner-module</a></li><li><a href="module-bestseller-module.html">bestseller-module</a></li><li><a href="module-bestseller-product-card.html">bestseller-product-card</a></li><li><a href="module-detail-recommend-module.html">detail-recommend-module</a></li><li><a href="module-discovery.html">discovery</a></li><li><a href="module-grid-navs.html">grid-navs</a></li><li><a href="module-header.html">header</a></li><li><a href="module-index.html">index</a></li><li><a href="module-more-product-card.html">more-product-card</a></li><li><a href="module-navs-module.html">navs-module</a></li><li><a href="module-recommend-product.html">recommend-product</a></li><li><a href="module-recommend-product-module.html">recommend-product-module</a></li><li><a href="module-single-product.html">single-product</a></li><li><a href="module-single-product-module.html">single-product-module</a></li><li><a href="module-special-product.html">special-product</a></li><li><a href="module-special-product-module.html">special-product-module</a></li><li><a href="module-title.html">title</a></li><li><a href="module-views.html">views</a></li>
				</ul>
			</li>
			
			<li class="dropdown">
				<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
				<ul class="dropdown-menu ">
					<li><a href="global.html#$t">$t</a></li><li><a href="global.html#appHandle">appHandle</a></li><li><a href="global.html#axiosRequestReject">axiosRequestReject</a></li><li><a href="global.html#axiosRequestResolve">axiosRequestResolve</a></li><li><a href="global.html#axiosResponseReject">axiosResponseReject</a></li><li><a href="global.html#axiosResponseResolve">axiosResponseResolve</a></li><li><a href="global.html#conversionTime">conversionTime</a></li><li><a href="global.html#current_locale">current_locale</a></li><li><a href="global.html#delay">delay</a></li><li><a href="global.html#deleteEmptyValue">deleteEmptyValue</a></li><li><a href="global.html#formaturl">formaturl</a></li><li><a href="global.html#getCurrentDate">getCurrentDate</a></li><li><a href="global.html#getCurrentLocale">getCurrentLocale</a></li><li><a href="global.html#getHiddenProp">getHiddenProp</a></li><li><a href="global.html#getLanguage">getLanguage</a></li><li><a href="global.html#getLanguageForBackEnd">getLanguageForBackEnd</a></li><li><a href="global.html#getLanguageOptions">getLanguageOptions</a></li><li><a href="global.html#getUploadImage">getUploadImage</a></li><li><a href="global.html#getVisibilityChangeEventName">getVisibilityChangeEventName</a></li><li><a href="global.html#i18n">i18n</a></li><li><a href="global.html#imgPreLoad">imgPreLoad</a></li><li><a href="global.html#importStyle">importStyle</a></li><li><a href="global.html#isContained">isContained</a></li><li><a href="global.html#isHidden">isHidden</a></li><li><a href="global.html#loading_toast">loading_toast</a></li><li><a href="global.html#messages">messages</a></li><li><a href="global.html#parseLanguageParameter">parseLanguageParameter</a></li><li><a href="global.html#parseQueryString">parseQueryString</a></li><li><a href="global.html#resizeModal">resizeModal</a></li><li><a href="global.html#setLanguageOptions">setLanguageOptions</a></li><li><a href="global.html#setLocale">setLocale</a></li><li><a href="global.html#setMinHeightToInnerHeight">setMinHeightToInnerHeight</a></li><li><a href="global.html#startLoading">startLoading</a></li>
				</ul>
			</li>
			
		</ul>
        
            <div class="col-sm-3 col-md-3">
                <form class="navbar-form" role="search">
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
                        <div class="input-group-btn">
                            <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
                        </div>
                    </div>
                </form>
            </div>
        
	</div>

</div>
</div>


<div class="container" id="toc-content">
<div class="row">

	
	<div class="col-md-12">
	
		<div id="main">
			

		<h1 class="page-title">Source: i18n/index.js</h1>
    
<section>
    <article>
        <pre
            class="sunlight-highlight-javascript linenums">/*
 * @Description: 多语言文件
 * @Author: kanglin
 * @Date: 2018-05-31 14:33:47
 * @Copyright: Created by Panxsoft.
 */
import Vue from 'vue';
import VueI18n from 'vue-i18n';
import { parseLanguageParameter } from 'src/utils/helper';
import zhCN from './languages/zh-cn';
import enUS from './languages/en-us';

Vue.use(VueI18n);

/**
 *  读取本地语言
 */
const current_locale = parseLanguageParameter(); // getCurrentLocale();
// Vue.config.lang = current_locale;
/**
 *  语言文件配置
 */
const messages = {
	'zh-CN': zhCN,
	'en-US': enUS,
};

/**
 * 配置 i18n
 */
export const i18n = new VueI18n({
	locale: current_locale,
	// fallbackLocale: 'zh-CN',
	messages,
});

/**
 * 切换语言
 * @param {string} locale
 */
export function setLocale(locale) {
	// Vue.config.lang = locale; // iview 的语言切换方式
	i18n.locale = locale; // i18n 的切换方式
}

/**
 * 翻译
 * @param {string} path
 * @param {object} options
 */
export function $t(path, options) {
	return i18n.t(path, options);
}

/**
 *  获取当前语言
 * @return {string} language
 */
export function getLanguage() {
	return i18n.locale;
}

const language = {
	options: 'zh-CN',
};

/**
 * 设置语言
 *  @return {string} language
 */
export function setLanguageOptions(name) {
	language.options = name;
}

/**
 * 获取语言选项
 *  @return {string} language
 */
export function getLanguageOptions() {
	return language.options;
}

/**
 *  后端的英文是 en , 中文是 zh-CN.
 */
export function getLanguageForBackEnd() {
	const MAP = { 'en-US': 'en-gb', 'zh-CN': 'zh-cn' };
	const lang = getLanguage();
	return MAP[lang] || 'zh-cn';
}
</pre>
    </article>
</section>





		</div>
	</div>

	<div class="clearfix"></div>

	

</div>
</div>


    <div class="modal fade" id="searchResults">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">Search results</h4>
          </div>
          <div class="modal-body"></div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div>


<footer>


<span class="jsdoc-message">
	Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
	
		on 2019-01-04T18:17:00+08:00
	
	using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>

<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>

    <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>


<script>
$( function () {
	$( "[id*='$']" ).each( function () {
		var $this = $( this );

		$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
	} );

	$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
		var $this = $( this );

		var example = $this.find( "code" );
		exampleText = example.html();
		var lang = /{@lang (.*?)}/.exec( exampleText );
		if ( lang && lang[1] ) {
			exampleText = exampleText.replace( lang[0], "" );
			example.html( exampleText );
			lang = lang[1];
		} else {
			var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
			lang = langClassMatch ? langClassMatch[1] : "javascript";
		}

		if ( lang ) {

			$this
			.addClass( "sunlight-highlight-" + lang )
			.addClass( "linenums" )
			.html( example.html() );

		}
	} );

	Sunlight.highlightAll( {
		lineNumbers : true,
		showMenu : true,
		enableDoclinks : true
	} );

	$.catchAnchorLinks( {
        navbarOffset: 10
	} );
	$( "#toc" ).toc( {
		anchorName  : function ( i, heading, prefix ) {
			return $( heading ).attr( "id" ) || ( prefix + i );
		},
		selectors   : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
		showAndHide : false,
		smoothScrolling: true
	} );

	$( "#main span[id^='toc']" ).addClass( "toc-shim" );
	$( '.dropdown-toggle' ).dropdown();

    $( "table" ).each( function () {
      var $this = $( this );
      $this.addClass('table');
    } );

} );
</script>



<!--Navigation and Symbol Display-->


<!--Google Analytics-->



    <script type="text/javascript">
        $(document).ready(function() {
            SearcherDisplay.init();
        });
    </script>


</body>
</html>
